package test;

import org.jing.core.lang.data.BaseSerializableDto;
import org.jing.core.lang.JingInitializer;
import org.jing.core.lang.annotation.SerializableField;
import org.jing.core.lang.annotation.SerializableType;
import org.jing.core.logger.JingLogger;
import org.jing.core.thread.ThreadInitializer;
import org.jing.core.thread.itf.BaseMultiplyThread;

/**
 * Description: <br>
 *
 * @author bks <br>
 * @since 2020-07-17 <br>
 */
public class Demo4ThreadFactory {
    private Demo4ThreadFactory() {
        JingInitializer.initialize(ThreadInitializer.class);
    }

    public static class Thread extends BaseMultiplyThread {
        private static final JingLogger LOGGER = JingLogger.getLogger(Thread.class);

        @Override public void execute() {
            LOGGER.debug("hello thread");
        }
    }

    public static class ThreadLoop extends BaseMultiplyThread<LoopConfiguration> {
        private static final JingLogger LOGGER = JingLogger.getLogger(ThreadLoop.class);

        @Override public void execute() {
            LOGGER.debug("hello thread-loop-{}", getConfig().index);
        }
    }

    @SerializableType
    private static class LoopConfiguration extends BaseSerializableDto {
        @SerializableField(value = "index", required = true)
        private int index;
    }

    public static void main(String[] args) {
        new Demo4ThreadFactory();
    }
}
